package com.wbp.cms.core.profileutil;

public class ProfileTest {

	public static void main(String[] args) {
		ProfileTest pt = new ProfileTest();
		
		//JProfiler.reset();
		JProfiler.start();
		pt.testProfile();
		String str = JProfiler.dump();
		
		System.out.println(str);
		//System.out.println("dump:test2:"+JProfiler.dump("test2Time"));
		//JProfiler.release();
		//long t = JProfiler.getDuration() ;
		//System.out.println("totalTime:"+t);
		JProfilerUtil.reset();
		
	}
	public void testProfile(){
		JProfiler.enter("testProfileTime");
		System.out.println("-----testProfile---------");
		try {
			Thread.sleep(2000L);
			test2();
			test4();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}finally{
			JProfiler.release();
		}
		
		
	}
	
	public void test2(){
		JProfiler.enter("test2Time");
		System.out.println("-----test2---------");
		try {
			Thread.sleep(2000L);
			
			test21();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			JProfiler.release();
			 long duration = JProfiler.getDuration();
			 System.out.println("duration:"+duration);
			 System.out.println(JProfiler.dump("Detail: ", "        "));
		        if(duration > (long)Math.max(500L, 1000L)) {
		            String.format("Order request returned in {0}ms\n{1}\n", Long.valueOf(duration), JProfiler.dump("Detail: ", "        "));
		        }
		}
	}
	
	public void test21(){
		JProfiler.enter("test21Time");
		System.out.println("-----test21---------");
		try {
			Thread.sleep(2000L);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			JProfiler.release();
			
		}
	}
	
	public void test4(){
		JProfiler.enter("test4Time");
		System.out.println("-----test4---------");
		try {
			Thread.sleep(2000L);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			JProfiler.release();
		}
	}
	
}
